package com.zkingsoft.actions.visitor;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zkingsoft.actions.common.BaseController;
import com.zkingsoft.anotations.RemoveRequestToken;
import com.zkingsoft.anotations.SaveRequestToken;
import com.zkingsoft.model.AdvertisementColumn;
import com.zkingsoft.model.AdvertisementPosition;
import com.zkingsoft.plugin.pojo.PaginationVO;
import com.zkingsoft.plugin.util.WebUtil;
import com.zkingsoft.pojo.AjaxResult;
import com.zkingsoft.services.AdvertisementColumnService;
import com.zkingsoft.services.AdvertisementPositionService;

/**
 * This field was generated by Zking.software.Codegen.
 * @date 2016-11-11 10:23
 */
@Controller
@RequestMapping(value = "/adPositionInterface")
public class AdPositionController extends BaseController{

	@Resource
	private AdvertisementPositionService currentService;
	@Resource
	private AdvertisementColumnService adColumnService;
	
	/**
	 * 
	 * @Description:根据广告栏名称，查询广告位
	 * @auther:罗袁宏
	 * @param columnName 广告栏名称
	 * @return
	 * 返回类型 :AjaxResult
	 * @date:2016年11月11日
	 */
 	@RequestMapping(value = "/adPosition")
	public @ResponseBody AjaxResult adPosition(AdvertisementColumn adColumn) {
 		//判断是否传参
 		if("".equals(adColumn.getColumnName())){
 			return new AjaxResult(AjaxResult.STATUS_ERR, null, "参数不全");
 		}
 		//查找广告栏
 		List<AdvertisementColumn> columnList = adColumnService.findByModel(adColumn);
 		//判断是否存在该广告栏
 		if(columnList.size()<=0){
 			return new AjaxResult(AjaxResult.STATUS_ERR, null,"暂无数据");
 		}
 		//查找该广告栏下的广告位
 		AdvertisementPosition adPosition = new AdvertisementPosition();
 		adPosition.setColumnId(columnList.get(0).getId());
 		List<AdvertisementPosition> positionList = currentService.findByModel(adPosition);
 		//判断该广告栏下是否有广告位
 		if(positionList.size()<=0){
 			return new AjaxResult(AjaxResult.STATUS_ERR, null,"暂无数据");
 		}
 		return new AjaxResult(AjaxResult.STATUS_OK, null, "广告位信息", positionList, positionList.size());
	}
}